#include <bits/stdc++.h>
using namespace std;
long long T,n,m,L,V,d[100005],v[100005],a[100005],p[100005],ans1,ans2;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&T);getchar();
    while(T!=0){
        T--;
        scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
        getchar();
        for(int i=1;i<=n;i++){
            scanf("%lld%lld%lld",&d[i],&v[i],&a[i]);
            getchar();
        }
        for(int i=1;i<=m;i++){
            scanf("%lld",&p[i]);
        }
        for(int i=1;i<=n;i++){
            long long dx=p[m]-d[i];
            if(dx>=0){
                long long dv_sq=2*a[i]*dx+v[i]*v[i];
                if(dv_sq>V*V){
                    ans1++;
                    ans2=1;
                }
            }
        }
        printf("%lld %lld",ans1,m-ans2);
    }
    return 0;
}
